package com.patelski.magic.service;

import com.patelski.magic.model.*;

import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import org.jboss.seam.log.Log;

import java.util.List;
import java.util.Arrays;

import javax.ejb.Stateful;

@Name("inventoryList")
public class InventoryList extends EntityQuery {

	private static final String[] RESTRICTIONS = {
			"lower(inventory.user.firstName) like concat('%',lower(#{inventoryList.user.firstName}),'%')",
			"lower(inventory.user.lastName) like concat('%',lower(#{inventoryList.user.lastName}),'%')",
			"lower(inventory.card.cardName) like concat('%',lower(#{inventoryList.card.cardName}),'%')", 
			"lower(inventory.note) like concat('%',lower(#{inventoryList.inventory.note}),'%')" };

	private Inventory inventory = new Inventory();
	private User user = new User();
	private Card card = new Card();

	@Override
	public String getEjbql() {
		return "select inventory from Inventory inventory";
	}

	@Override
	public Integer getMaxResults() {
		return 150;
	}

	public Inventory getInventory() {
		return inventory;
	}

	@Override
	public List<String> getRestrictions() {
		return Arrays.asList(RESTRICTIONS);
	}

	@Override
	public String getOrder() {
		return "inventory.card.cardName asc";
	}
	
	public Card getCard() {
		return card;
	}

	public void setCard(Card card) {
		this.card = card;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
